﻿
Partial Class Hosteria_VS_Reservas

    Inherits System.Web.UI.Page

    Dim startMode As String

    Protected Sub fvReservas_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles fvReservas.Load
        If Session("addOne") IsNot Nothing Then
            If Session("addOne") = "Yes" Then
                fvReservas.ChangeMode(FormViewMode.Insert)
                DirectCast(fvReservas.FindControl("IdHabitacionTextBox"), TextBox).Text = Session("habitacion")
                DirectCast(fvReservas.FindControl("IdHabitacionTextBox"), TextBox).ReadOnly = True
                DirectCast(fvReservas.FindControl("DesdeTextBox"), TextBox).Text = Session("desde")
                DirectCast(fvReservas.FindControl("DesdeTextBox"), TextBox).ReadOnly = True
                DirectCast(fvReservas.FindControl("HastaTextBox"), TextBox).Text = Session("hasta")
                DirectCast(fvReservas.FindControl("HastaTextBox"), TextBox).ReadOnly = True
                fvReservas.FindControl("ANombreDeTextBox").Focus()
            End If
        End If
    End Sub

    Protected Sub InsertCancelButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If Session("addOne") <> Nothing Then
            Session("addOne") = Nothing
            Session("habitacion") = Nothing
            Session("desde") = Nothing
            Session("hasta") = Nothing
            Server.Transfer("Disponibilidad.aspx")
        End If
    End Sub

    Protected Sub fvReservas_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles fvReservas.ItemInserted
        If Session("addOne") <> Nothing Then
            SqlDataSource1.SelectParameters("IdHabitacion").DefaultValue = Session("Habitacion").ToString
            SqlDataSource1.Select(DataSourceSelectArguments.Empty)
            fvReservas.ChangeMode(FormViewMode.ReadOnly)
            Session("addOne") = Nothing
            Session("habitacion") = Nothing
            Session("desde") = Nothing
            Session("hasta") = Nothing
            lblReservaConfirmada.Visible = True
        End If
    End Sub


    Protected Sub SqlDataSource1_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles SqlDataSource1.Inserted
        If (e.Exception IsNot Nothing) Then
            e.ExceptionHandled = True
            Return
            'Else
            'MsgBox(e.Exception.Message.ToString)
        End If
    End Sub

    Protected Sub InsertButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        Session("addOne") = "No"
    End Sub
End Class
